/*
 * @Author: hzm 
 * @Date: 2020-06-20 21:47:24 
 * @Last Modified by: hzm
 * @Last Modified time: 2020-06-20 21:54:48
 */

#pragma once
#include "Event.h"
#include <memory>

namespace HeyIM {

class PipeEvent: public Event {

public:

    PipeEvent(event_base* base, VoidParamHandler handler);
    PipeEvent(const PipeEvent&) = delete;
    PipeEvent& operator=(const PipeEvent&) = delete;

    virtual~PipeEvent();

    virtual void init() override;

    void post();

    virtual void destroy() override;

protected:

    static void pipeHandleCallback(int fd, short flag, void* arg);

    int m_pipe[2];

};

typedef std::shared_ptr<PipeEvent> PipeEventPtr;

}